//
//  ViewController.m
//  02-UIViewController
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UIView *subView;
@end

@implementation ViewController
// ViewController的生命周期
//1。初始化方法
- (instancetype) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
//         不要再这个方法中，去加载试图
//        再这个方法中去初始化一些数据相关的内容
    }
    return self;
}

//2.loadView 加载 UIViewController 中的 View
//UINavigation UITableViewController 在loadView中 给重新赋值了
- (void)loadView {
    [super loadView];
    NSLog(@"loadView");
//    改变self.view
}

  // 注意： loadView viewDidLoad 只执行一次
// view 已经 加载
// 3.所有自定义试图的创建
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"viewDidLoad");
//    self.view = nil;
//    NSLog(@"%@", self.view);
//    模态
    
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    PresentViewController *present = [[PresentViewController alloc] init];
//    模态 动画效果
//    UIModalTransitionStyleCoverVertical 默认效果， 从下往上
//    UIModalTransitionStyleFlipHorizontal 左右旋转翻页
//    UIModalTransitionStyleCrossDissolve 渐变效果
//    UIModalTransitionStylePartialCurl 翻书效果
    present.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
//    模态， 一个试图控制器
    [self presentViewController:present animated:YES completion:nil];
}




//下述方法会执行多次的
// 试图将要出现时
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"viewWillAppear");
}
//试图已经出现时
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
     NSLog(@"viewDidAppear");
}
//试图将要消失时
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
     NSLog(@"viewWillDisappear");
}
// 试图已经消失时
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
     NSLog(@"viewDidDisappear");
}
// 懒加载
//- (UIView *)subView {
//    if (_subView == nil) {
//        _subView = [UIView new];
//        [self loadView];
//    }
//    return _subView;
//}

//接收到内存警告时， 执行的方法
- (void)didReceiveMemoryWarning {
    // 从父类继承来的方法中有内存警告的打印
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
     // 释放部分内存资源
     // 把未显示在屏幕上的资源置空
}

@end
